package compound.pattern;import java.util.ArrayList;import java.util.Iterator;/** * Created by Administrator on 2018-11-8. */public class Observable implements QuackObservable {    ArrayList observes =new ArrayList();    QuackObservable duck;    public Observable(QuackObservable duck){        this.duck =duck;    }    public void registerObserver(Observer observer) {        observes.add(observer);    }    public void notifyObservers() {        Iterator i = observes.iterator();        while (i.hasNext()){            Observer observer = (Observer)i.next();            observer.update(duck);        }    }}